home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / p / parbench / parbenchv3.1.dms / parbenchv3.1.adf / Extras / ParNETSource.LHA / parnet / test / get.c < prev    next >
C/C++ Source or Header  |  1990-02-08  |  2KB  |  84 lines

  1.  
  2. /*
  3.  *  GET.C
  4.  *
  5.  *  GET port
  6.  *
  7.  *  receives data from port and prints results, massive receive w/ multiple
  8.  *  requests queued.
  9.  */
  10.  
  11. #include "/parnet/defs.h"
  12.  
  13. #define REQS    8
  14.  
  15. typedef struct IORequest IOR;
  16.  
  17. Iob iob[REQS];
  18. char Buf[8192];
  19.  
  20. int
  21. brk()
  22. {
  23.     return(0);
  24. }
  25.  
  26. void
  27. main(ac, av)
  28. char *av[];
  29. {
  30.     PORT *port = CreatePort(NULL, 0);
  31.     long bytes = 0;
  32.     short i;
  33.     long j;
  34.  
  35.     onbreak(brk);
  36.     iob[0].io_Message.mn_ReplyPort = port;
  37.     iob[0].io_Port = atoi(av[1]);
  38.     iob[0].io_Flags= PRO_DGRAM;
  39.  
  40.     if (OpenDevice("parnet.device", 0, (IOR *)&iob[0], 0)) {
  41.     printf("Unable to open parnet.device, error %d %d\n", iob[0].io_Error, iob[0].io_Actual);
  42.     exit(1);
  43.     }
  44.     printf("Device $%08lx Unit $%08lx\n", iob[0].io_Device, iob[0].io_Unit);
  45.  
  46.     iob[0].io_Command = CMD_READ;
  47.     iob[0].io_Data    = (APTR)Buf;
  48.     iob[0].io_Length  = sizeof(Buf);
  49.  
  50.     for (i = 1; i < REQS; ++i)
  51.     iob[i] = iob[0];
  52.     for (i = 0; i < REQS; ++i)
  53.     SendIO((IOR *)&iob[i]);
  54.  
  55.     j = 0;
  56.  
  57.     for (;;) {
  58.     long mask;
  59.     Iob *io;
  60.  
  61.     mask = Wait(SIGBREAKF_CTRL_E | (1 << port->mp_SigBit));
  62.  
  63.     if (mask & SIGBREAKF_CTRL_E)
  64.         break;
  65.  
  66.     while (io = (Iob *)GetMsg(port)) {
  67.         bytes += io->io_Actual;
  68.         SendIO((IOR *)io);
  69.         ++j;
  70.         if ((j & 15) == 0)
  71.         printf("Got %3ld %dK\n", j, bytes >> 10);
  72.     }
  73.     }
  74.     printf("Aborting...\n");
  75.     for (i = 0; i < REQS; ++i) {
  76.     AbortIO((IOR *)&iob[i]);
  77.     WaitIO((IOR *)&iob[i]);
  78.     }
  79.     printf("Closing...\n");
  80.     CloseDevice((IOR *)&iob[0]);
  81.     DeletePort(port);
  82. }
  83.  
  84.